# -*- coding: utf-8 -*-
"""
-------------------------------------------------
   File Name：     day133_pyqt5_mysignal.py
   Description :
   Author :       fuml
   date：          2019/9/21
-------------------------------------------------
   Change Activity:
                   2019/9/21:In this example, we determine the event sender
object.
 -------------------------------------------------
"""
import sys

from PyQt5.QtCore import pyqtSignal,QObject
from PyQt5.QtWidgets import QMainWindow,QApplication

class Communicate(QObject):
    closeApp = pyqtSignal()

class Example(QMainWindow):
    def __init__(self):
        super().__init__()
        self.initUI()

    def initUI(self):
        self.c = Communicate()
        self.c.closeApp.connect(self.close)

        self.setGeometry(300, 300, 250, 150)
        self.setWindowTitle('emit signal')
        self.show()
    def mousePressEvent(self, *args, **kwargs):
        self.c.closeApp.emit()

if __name__ == '__main__':
    app= QApplication(sys.argv)
    ex = Example()
    sys.exit(app.exec_())